
export class Range {
  min = 0;
  max = 0;
  step = 1;

  constructor(min = 0, max, step = 1) {
    if (max == undefined) {
      max = min;
      min = 0;
    }
    this.min = min;
    this.max = max;
    this.step = step;
  }

  size() {
    return Math.ceil((this.max - this.min) / this.step);
  }

  toFullArray() {
    return Array(this.size()).fill(this.min).map((v, i) => v + this.step * i);
  }

  toArray() {
    return [this.min, this.max, this.step];
  }

  static fromArray([min, max, step]) {
    return new Range(min, max, step);
  }
}
